import Vue from 'vue'
import Vuex from 'vuex'
import getters from './getters'

Vue.use(Vuex)

function importAllModules() {
  const context = require.context('./modules', true, /.+\.js$/)
  const modules = {}
  context.keys().forEach(key => {
    modules[key.replace(/^.+\/(.+)\.js$/, '$1')] = context(key).default
  })
  return modules
}
const store = new Vuex.Store({
  modules: importAllModules(),
  getters
})

export default store
